#include <iostream>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <cerrno>
#include <cstring>

const std::string comm_name = "./myfifo";

int main()
{
    //client以写打开管道
    int fd = open(comm_name.c_str(),O_WRONLY);
    if(fd < 0)
    {
        std::cout<<"open fail"<<errno<<std::endl;
    }
    int cent = 100;
    sleep(5);
    while(cent--)
    {
        sleep(1);
        std::cout<<"client begin write"<<std::endl;
        //消息拼接
        std::string message = "i sent a message ,cnet: ";
        message += std::to_string(cent);
        //写入消息
        ssize_t n = write(fd,message.c_str(),sizeof(message));
    }
    return 0;
}